/**
 * 
 */


import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 * @author varun
 * varun11
 */
public class varun {

        /**
         * @param args
         * @throws IOException
         * This program looks for repeated words line by line in the file and prints the repeated words in the console
         */
        public static void main(String[] args) throws IOException {

                try { // surrounded by the try and catch blocks
                        /**
                         *  Opens the file from the location specified                   
                         **/
                        FileInputStream fstream = new FileInputStream(
                        		args[1]);
                        // Get the object of DataInputStream
                        DataInputStream in = new DataInputStream(fstream);
                        BufferedReader br = new BufferedReader(new InputStreamReader(in));//gets the buffered reader
                        String strLine;
                        //This will Take the File in and Reads it Line By Line
                        int i = 0;
                        while ((strLine = br.readLine()) != null) {
                                i++;
                                StringTokenizer st = new StringTokenizer(strLine, " ");
                                String matchStr = null;
                                String token = null;
                                while (st.hasMoreElements()) {
                                        token = st.nextToken();
                                        if (token.equalsIgnoreCase(matchStr)//Made it case-insensitive
                                                        && !(matchStr.equals(null))) {
                                                System.out.println("Repeated word on line " + i + ":"
                                                                + token + " " + matchStr);
                                        }
                                        matchStr = token;

                                }

                        }
                        // Close the input stream
                        in.close();
                } 
                /**
                 * All the exceptions are caught here 
                 */
                catch (Exception e) {
                        System.err.println("Error: " + e.getMessage());// Print the error message if any..
                }
                /**
                 * Stut file.
                 *
                 * This program uses the same logic as the stutter.c, like reading the character 
                 * by character, and comparing the subsequent words.
                 *
                 * @param file the file
                 * 
                 */
                {
                        char c;
                        char[] a, b;
                        //TODO try to the same logic as stutter.c
                }
               
               
                     
             }

        }



